#include<iostream>
#include<cmath>
using namespace std;

template<typename T, size_t N>
int sum_prime(T (&arr)[N])
{
    memset(arr,1,sizeof(arr));
    int ret=0;
    int SQRT = (int)sqrt(N)+1;
    for( int i =3; i < SQRT; i+=2)
    {
        if(arr[i])
        {
            for(int j=i*i;j<N; j+=i*2)
            {
                arr[j]=0;
            }
        }
    
    }

    for( int i =3; i <N; i+=2)
    {
        if( arr[i] )
            ret += i;
            
    }
    return ret+2;
    
}

int main()
{
    const int runcount = 10000;
    char arr[10001];
    clock_t s = -clock();
    int v=0;
    for( int i = 0; i < runcount; ++ i)
        v = sum_prime(arr);
    s += clock();
    cout<<"Result: = "<<v<<endl;
    cout<<"ms per run: = "<<(float(s) * 1000 / CLOCKS_PER_SEC / runcount);
    return 0;
}
